package com.taritari.journal.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.taritari.journal.entity.vo.SentimentClassify;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author taritari
 * @date 2024-01-11 20:17
 * @description 情感趋势表
 */
@Mapper
public interface SentimentClassifyMapper extends BaseMapper<SentimentClassify> {
    /**
     * 查询是否存在日记的情感趋势
     * 用于mq判断是否添加还是修改
     * */
    int querySentimentIsExit(String number);
    /**
     * 公告作者id查询所有分析的日记
     * */
    @Select("SELECT `text` FROM `sentiment_classify` WHERE author_id = #{authorId}")
    List<String> queryJournalNumberByAuthorId(int authorId);
    /**
     * 通过作者获取心情指数
     * */
    @Select("SELECT AVG(positive_prob) as positive,AVG(negative_prob) AS negative FROM `sentiment_classify` WHERE author_id = #{authorId} GROUP BY author_id")
    Map<String,Double> querySentimentByAuthorId(int authorId);
}
